/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package backing;

import java.util.List;
import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import officeboost.domain.EquipmentService;
import officeboost.domain.equip_venue.Equipment;



/**
 *
 * @author XJ
 */
@ManagedBean
public class EquipmentAdminBacking extends AbstractBacking{
    
    @EJB
    private EquipmentService equipmentService;
    private List<Equipment> equList;
    private String number;
    private String name;
    private String usage;
    private String numtodelete;
    
    public String getNumtodelete() {
        return numtodelete;
    }

    public void setNumtodelete(String numtodelete) {
        this.numtodelete = numtodelete;
    }
    
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getNumber() {
        return number;
    }

    public void setNumber(String number) {
        this.number = number;
    }

    public String getUsage() {
        return usage;
    }

    public void setUsage(String usage) {
        this.usage = usage;
    }
    
    public List<Equipment> getEquList() {
        return equList;
    }

    public void setEquList(List<Equipment> equList) {
        this.equList = equList;
    }


    
     public void init(){
       
         this.setEquList(equipmentService.findAll());
        // this.equList.add((Equipment)getSessionMap().get("equip"));
     }
    
     public String addEquipment(){         
         Equipment eq=new Equipment();
         eq.setId(this.number);        
         eq.setName(this.name);
         eq.setTheUsage(this.usage);
         eq.setStatus("availiable");
         
        // getSessionMap().put("equip", eq);
         
         equipmentService.persist(eq);
         return "equipment";
     }
     
     public String deleteEquipment(){
      
         equipmentService.deleteById(this.numtodelete);
         
         return "equipment";
     }
}
